#!/bin/bash
# Script to calculate the band structure of Graphene

# Get the number of processors, by default, 1
if [ "$#" -ge 1 ]; then
   np=$1
else
   np=4
fi

# Step 1: SCF calculation (uniform k-mesh)
rm -rf INCAR KPOINTS
ln -s  INCAR.1 INCAR
ln -s  KPOINTS.1 KPOINTS

mpirun --allow-run-as-root -np ${np} vasp

# Step 2: NSCF calculation (DOS, uniform but denser)
rm -rf INCAR KPOINTS
ln -s  INCAR.2 INCAR
ln -s  KPOINTS.2 KPOINTS

mpirun --allow-run-as-root -np ${np} vasp

mv DOSCAR DOSCAR.dos

# Step 3: NSCF calculation (band structure, line mode)
rm -rf INCAR KPOINTS
ln -s  INCAR.3 INCAR
ln -s  KPOINTS.3 KPOINTS

mpirun --allow-run-as-root -np ${np} vasp

# clean up
rm -rf CHG CONTCAR OSZICAR PBS.batch PCDAT XDATCAR

# Now the DOSCAR does contain the DOS from step 2
mv DOSCAR.dos DOSCAR
